﻿@page "/mine"
@using SwashbucklerDiary.Models
@inherits PageComponentBase

<link href="css/extend/masa-blazor-extend-enqueued-snackbars.css" rel="stylesheet" />

<MAppBar App="true"
         Elevation="0">
    <MToolbarTitle Class="font-weight-bold">
        @(I18n.T("Mine.Mine"))
    </MToolbarTitle>
    <MSpacer></MSpacer>
    <MButton Large
             Icon
              OnClick="@(()=>To("searchAppFunction"))">
         <MIcon>mdi-magnify</MIcon>
     </MButton>
 </MAppBar>

 <ScrollContainer>
     <div class="d-sm-flex flex-sm-row justify-space-between">
         <MHover>
             <MCard @attributes="context.Attrs"
                    Class="@($"mine-info mb-5 py-sm-3 py-md-5 {(context.Hover?"elevation-sm-2":"")}")"
                    Elevation="0"
                    Rounded="@("lg")"
                    Ripple="false"
                    OnClick="@(()=>To("user"))">
                 <MList>
                     <MListItem ThreeLine>
                        <MListItemAvatar Class="ml-sm-2 ml-md-4"
                                         Rounded="@("lg")"
                                         Size="70">
                            <MImage Src="@(Avatar)">
                                <PlaceholderContent>
                                    <MRow Class="fill-height ma-0"
                                          Align="@AlignTypes.Center"
                                          Justify="@JustifyTypes.Center">
                                        <MProgressCircular Indeterminate="true">
                                        </MProgressCircular>
                                    </MRow>
                                </PlaceholderContent>
                            </MImage>
                        </MListItemAvatar>
                        <MListItemContent>
                            <MListItemTitle Class="text-h6 font-weight-bold">
                                @(string.IsNullOrEmpty(UserName) ? I18n.T("AppName") : UserName)
                            </MListItemTitle>
                            <MListItemSubtitle>
                                @(string.IsNullOrEmpty(Sign) ? I18n.T("Mine.Sign") : Sign)
                            </MListItemSubtitle>
                        </MListItemContent>
                        <MListItemAction Style="align-self:unset;">
                            <MIcon>mdi-chevron-right</MIcon>
                        </MListItemAction>
                    </MListItem>
                </MList>
            </MCard>
        </MHover>

        <MCard Class="mine-info mb-5 ml-sm-5 d-flex"
               Elevation="0"
               Rounded="@("lg")">
            <MList Class="d-flex flex-grow-1">
                <MListItem>
                    <MListItemContent Class="justify-space-around text-center">
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Mine.DiaryCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @DiaryCount
                            </MListItemTitle>
                        </div>
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Mine.WordCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @WordCount
                            </MListItemTitle>
                        </div>
                        <div style="flex:unset">
                            <MListItemSubtitle>
                                @(I18n.T("Mine.ActiveDayCount"))
                            </MListItemSubtitle>
                            <MListItemTitle Class="mt-2 font-weight-bold text-h6">
                                @ActiveDayCount
                            </MListItemTitle>
                        </div>
                    </MListItemContent>
                </MListItem>
            </MList>
        </MCard>
    </div>

    @foreach (var list in ViewLists)
    {
        <div class="text-h6 mine-title">
            @(I18n.T(list.Key))
        </div>

        <MCard Class="mine-card"
               Elevation="0"
               Rounded="@("lg")">
            <MList>
                @foreach (var item in list.Value)
                {
                    <MListItem OnClick="()=>item.OnClick.InvokeAsync()">
                        <MListItemIcon>
                            <MIcon Class="list-item-icon">
                                @(item.Icon)
                            </MIcon>
                        </MListItemIcon>
                        <MListItemContent>
                            @(I18n.T(item.Text))
                        </MListItemContent>
                        <MListItemAction>
                            <MIcon>mdi-chevron-right</MIcon>
                        </MListItemAction>
                    </MListItem>

                    if (list.Value.Last() != item)
                    {
                        <MDivider Class="mx-3"></MDivider>
                    }
                }

            </MList>
        </MCard>
    }

</ScrollContainer>

<MMDialog @bind-MyValue="ShowLanguage"
          MaxWidth="420">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Mine.SelectLanguage"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>ShowLanguage= false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText>
            <MRadioGroup Value="Language"
                         TValue="string"
                         ValueChanged="LanguageChanged"
                         Class="mt-0 pb-1"
                         OnClick="()=>ShowLanguage=false"
                         HideDetails="@("auto")"
                         Mandatory="true">
                @foreach (var item in Languages)
                {
                    <MRadio Label="@(item.Key)"
                            Class="my-2"
                            Value="@(item.Value)"
                            Color="@MRadioColor">
                    </MRadio>
                }
            </MRadioGroup>
        </MCardText>
    </MCard>
</MMDialog>

<MMDialog @bind-MyValue="ShowThemeState"
          MaxWidth="420">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Mine.Night"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>ShowThemeState= false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText>
            <MRadioGroup Value="ThemeState"
                         TValue="ThemeState"
                         ValueChanged="ThemeStateChanged"
                         Class="mt-0 pb-1"
                         OnClick="()=>ShowThemeState=false"
                         HideDetails="@("auto")"
                         Mandatory="true">
                @foreach (var item in ThemeStates)
                {
                    <MRadio Label="@(I18n.T(item.Key))"
                            Class="my-2"
                            Value="@(item.Value)"
                            Color="@MRadioColor">
                    </MRadio>
                }
            </MRadioGroup>
        </MCardText>
    </MCard>
</MMDialog>

<MultiDialog @bind-Value="ShowFeedback"
             Title="@(I18n.T("Mine.ContactWay"))"
             ListItemModels="FeedbackTypes">
</MultiDialog>